package com.project.controller;

import com.project.bean.OrderBean;
import com.project.bean.UserBean;
import com.project.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private IOrderService service;
    @RequestMapping("custom/add")
    public String addOrder(OrderBean order , HttpServletRequest req){
        //从session中取出登陆用户
        UserBean user = (UserBean) req.getSession().getAttribute("loginUser");
        //设置用户ID
        order.setUserId(user.getId());
        //添加订单
        service.addOrder(order);
        return "ok";
    }
}
